package com.mesd.killer.ui.cellEditor;

import java.awt.Color;
import java.awt.Component;

import javax.swing.AbstractCellEditor;
import javax.swing.JCheckBox;
import javax.swing.JLabel;
import javax.swing.JTable;
import javax.swing.SwingConstants;
import javax.swing.table.TableCellEditor;

public class CheckBoxEditor extends  AbstractCellEditor implements TableCellEditor {
	protected JCheckBox checkBox;  
	 
	public CheckBoxEditor()
	{
		 checkBox = new JCheckBox();  
         checkBox.setHorizontalAlignment(SwingConstants.CENTER);  
         checkBox.setBackground( Color.white); 
	}
	
	@Override
	public Object getCellEditorValue() {
		return Boolean.valueOf(checkBox.isSelected());  
	}

	@Override
	public Component getTableCellEditorComponent(JTable table, Object value,
			boolean isSelected, int row, int column) {
		     if(value == null)
		    	 return new JLabel("");
		     
			 checkBox.setSelected(((Boolean) value).booleanValue());  
			 return checkBox;
	}  

}
